Repository navigation
Serialized magnets: consistent accessors in design and live, family used as a single magnet in arrays - #481
Conversation
23809d0 to
51033f5
Compare
A serialized family (N magnets on one power supply) has a single degree of freedom, the PS current I. The accessors now follow that in design and live: - family.hardware returns I (was N x I) and sets I. - family.strength returns the average strength sum(f_i(I))/N and sets the I that gives it (exact inverse of the piecewise-linear curves). - magnet[i].strength sets I = f_i^-1(x) with the magnet's own submodel; the other magnets follow. Design no longer splits the value by length. - Array writes give the PS the mean of the currents asked by the series members present in the array, not by all N, so writing one member no longer moves the PS by 1/N. Inconsistent requests log a warning. Design arrays (no aggregator) apply the same rule as live. Combined-function magnets keep their current behaviour: the strength aggregator now calls MagnetModel.compute_hardware_values_partial(), whose default is the previous logic; LinearSerializedMagnetModel overrides it. Also: - Build the serialized submodels once, at configuration. Attaching a family used to rebuild them, so the per-magnet accessors kept stale submodels that never received the magnetic rigidity. - SerializedMagnetsArray.unit() no longer splits unit strings into characters. - Remove ReadWriteSerializedStrengths.elements / get_elements(); use SerializedMagnets.get_magnets(). Tests: new design/live tests for idempotence, family values, per-magnet writes, design/live parity and array writes; tests that relied on the sum and length-sharing convention are updated. Refs #461 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d completed partial requests for serialized magnets (#461)
… strength is clamped to the excitation curve
… strength is clamped to the excitation curve
SerializedMagnets derives from Magnet, its members are not added to an array that holds it, pyaml.arrays.serialized_magnet is deprecated.
51033f5 to
f5d4ece
Compare
|
It looks like this PR is ready for review. |
|
Tests with the SOLEIL configuration on design mode seem to run fine, I'll also test on the real machine on the 30/11. I only found one issue when writing an array holding two magnets of the same series, with arr a MagnetArray like [QF1A-C05, QF1A-C06]: |
I'm on it. It's not as easy as I first thought. I'm creating a new PR for this. |
The power supply gets the average of the values of the magnets of the series present in the array, in design and live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Applies to strengths and hardwares, in design and live, before anything is written. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…alized-array-hardwares Serialized magnets: write the power supply once from array hardware values
|
I made a very small change to have the same error behaviour for |
family.strengths.set() with a single number crashed with a bare TypeError. It now raises a PyAMLException before anything is written unless it gets one value per magnet, as family.hardwares.set() already does. Also fix the Returns underline in the MagnetModel.shares_power_supply docstring. Refs #461 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
At last ! |
|
@kparasch, I think we should wait for your PRs to be merged, and then we'll be good to go. |
@gupichon-soleil I don't think we need to wait for them. PR #518 can be merged but since a rebase is anyway needed I can just rebase to main after this is merged as it is quite independent. PR #521 can wait until I have completed the specialization of |
|
Great, then let's merge this. |
Resolve the conflicts with the serialized-magnet rework (#481, #516): - Keep main's serialized family accessors and apply the SI unit conventions to them: a single unit when values share it, the standard unit() docstring, control_system_unit() on hardware accessors. The family average strength reports its pyAML unit, since no device holds it. - Build the CSHardwareScalarAggregator with SI device access and give it per-magnet unit() and control_system_unit(): the inherited ones listed one unit per power supply. - Take main's deprecated SerializedMagnetsArray, which now relies on the unit handling of MagnetArray. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Summary
A serialized family (N magnets on one power supply) has a single degree of freedom, the power supply current I. This PR makes every accessor follow that rule, with the same behaviour in
designandlive, and turns the family into a specialMagnetthat magnet arrays hold as one element.Closes #461, #473, #507
Accessor convention (#461, #473)
family.hardwarereads and writes I (it used to return N x I).family.strengthreads the mean strengthsum(f_i(I)) / Nand writes the I that gives it.magnet[i].strengthwritesI = f_i^-1(x)with that magnet's own submodel. The other magnets of the series follow.designno longer splits a value by magnet length.MagnetModel.compute_hardware_values_partial(), whose default is the previous logic, andLinearSerializedMagnetModeloverrides it.Inverse of the excitation curves
Arrays (#507)
SerializedMagnetsderives fromMagnet. A magnet array that holds a family contains the family as one element, its members are never expanded.pyaml.arrays.serialized_magnetis deprecated.Other fixes
SerializedMagnetsArray.unit()no longer splits unit strings into characters.ReadWriteSerializedStrengths.elements/get_elements()are removed, useSerializedMagnets.get_magnets().Tests
tests/magnet/test_serialized_family_as_magnet.py,test_serialized_magnets_cs.py,test_serialized_magnets_expected_behaviour.py).tests/config/sr_serialized_magnets_range.yamlfor curves with different current ranges.🤖 Generated with Claude Code